package com.haibara.codesubmiteval.context;


import com.haibara.codesubmiteval.model.entity.User;

/**
 * 用户上下文信息
 *
 * @Author: mengyu
 * @Date: 2024/12/12
 */
public class UserContext {
    private static final ThreadLocal<User> threadLocal = new ThreadLocal<>();

    public static void set(User user) {
        threadLocal.set(user);
    }

    public static User get() {
        return threadLocal.get();
    }

    public static boolean hasValue() {
        return threadLocal.get() != null;
    }

    public static void remove() {
        threadLocal.remove();
    }
}
